package servlet;

import dao.CartDAO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name="cartUpdateNum",value = "/cart/updateNum")
public class CartUpdateNumServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
        //获取post请求参数乱码问题
        req.setCharacterEncoding("UTF-8");
        String id=req.getParameter("id");
        String num=req.getParameter("num");

        Integer num1=Integer.parseInt(num);
        CartDAO cartDAO=new CartDAO();
        cartDAO.updateNum(id,num1);
        req.getRequestDispatcher("/cart/list").forward(req,resp);
    }

}
